import multiprocessing as mp
from multiprocessing.dummy import Pool as ThreadPool
import os

# 子进程要执行的代码
def run_proc(i, hello):
    print('启动线程' + str(os.getppid()))
    return str(str(i) + hello)


def x_y(args):
    return run_proc(args[0], args[1]),

def xy(hello):
    z = []
    for i in range(100):
        z.append([i, hello])
    return z

if __name__=='__main__':
    # p = mp.Process(target=run_proc, args=('test',))
    # p.start()
    # p.join()
    res = []
    pool = ThreadPool(processes = 100)
    for i in range(1000000):
        results = pool.apply_async(run_proc, args = (i, "hello",))
        res.append(results.get())

    pool.close()
    pool.join()
    print(res)
    # x = xy('hello')
    # pool = ThreadPool(processes = 100)
    # res = pool.map_async(run_proc, x)
    # res.wait()
    # print(res.get())

